<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <!--{include file='comm/header.tpl'}-->
    <!--{include file='comm/comm_editor.tpl'}-->
    <title>入库单导入</title>
</head>

<body>
<div style="padding: 10px;">

    <div class="panel panel-default">
        <div class="panel-heading">正在操作：导入货位号</div>
        <div class="panel-body">

            <form  class="form-horizontal"  method="POST" onsubmit="return false;">

                <div class="form-group">
                    <label for="storeID" class="col-sm-2 control-label">选择仓库 <font color="red">*</font></label>
                    <div class="col-sm-10">
                        <select class="form-control col-sm-2" id='storeID' name='storeID' style="width: 200px;">
                            <option value=''>请选择</option>
                            <!--{foreach from=$store_array item=value}-->
                            <option value='<!--{$value->storeID}-->'<!--{if $storeID == $value->storeID}--> selected <!--{/if}--> ><!--{$value->storeName}--></option>
                            <!--{/foreach}-->
                        </select>
                    </div>
                </div>

                <div class="form-group">
                    <label for="loadFile" class="col-sm-2 control-label">导入入库单</label>
                    <div class="col-sm-10">
                        <input type="button" class="btn btn-warning" value="选择文件" id="loadFile">
                    </div>
                </div>

            </form>

        </div>
    </div>



</div>

<script type="text/javascript">

    KindEditor.ready(function(K) {
        var editor = K.editor({
            allowFileManager : true,
            uploadJson: '/framework/kindeditor/php/upload_json.php?act=userdefined'
        });

        $(document).on('click','#loadFile',function(){

            editor.loadPlugin('insertfile', function() {
                editor.plugin.fileDialog({
                    showRemote : false,
                    clickFn : function(url) {
                        $(".ke-dialog").hide();
                        $(".ke-dialog-mask").hide();
                        //ajax提交执行文件解析
                        var storeName = $('#storeID').text();
                        var storeID =   $('#storeID').val();
                        if(storeID == ''){
                            E.alert('请先选择仓库');
                            $('#storeID').focus();
                            return false;
                        }

                        E.loadding.open();
                        $.ajax({
                            type: 'POST',
                            url: "/invokingAjax-backend/wms/putInStore.ajax?operFlg=6",
                            dataType: "JSON",
                            data: {fileName  : url,
                                    storeName: storeName,
                                    storeID  : storeID
                            },
                            success: function( result_obj ) {
                                E.loadding.close();
                                if(result_obj.code == 200){
                                    E.alert(result_obj.message, 2);
                                }else{
                                    E.alert(result_obj.message);
                                }

                            }
                        });
                    }
                });

            });
        });
    });
</script>

</body>

</html>
